package ua.kharkov.khpi.tarasenko.bach.dao.derby;

import java.sql.Connection;

import org.apache.log4j.Logger;

import ua.kharkov.khpi.tarasenko.bach.core.db.EShopDataStoreException;
import ua.kharkov.khpi.tarasenko.bach.dao.core.DAOFactory;
import ua.kharkov.khpi.tarasenko.bach.dao.core.category.CategoryDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.item.ItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.order.OrderItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.order.OrderUserDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.core.user.UserDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.derby.category.DerbyCategoryDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.derby.item.DerbyItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.derby.order.DerbyOrderItemDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.derby.order.DerbyOrderUserDAO;
import ua.kharkov.khpi.tarasenko.bach.dao.derby.user.DerbyUserDAO;

/**
 * Provide ability to create DAO's for DERBY database.
 * 
 * @author oleksandr
 *
 */
public class DerbyDAOFactory extends DAOFactory {
	private static final Logger log = Logger.getLogger(DerbyDAOFactory.class);
	
	@Override
	public UserDAO getUserDAO(Connection conn) throws EShopDataStoreException {
		if (log.isTraceEnabled()){
			log.trace("Creating new DerbyUserDAO");
		}
		return new DerbyUserDAO(conn);
	}

	@Override
	public ItemDAO getItemDAO(Connection conn) throws EShopDataStoreException {
		if (log.isTraceEnabled()){
			log.trace("Creating new DerbyItemDAO");
		}
		return new DerbyItemDAO(conn);
	}

	@Override
	public CategoryDAO getCategoryDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()){
			log.trace("Creating new DerbyCategoryDAO");
		}
		return new DerbyCategoryDAO(conn);
	}

	@Override
	public OrderUserDAO getOrderUserDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()){
			log.trace("Creating new DerbyOrderUserDAO");
		}
		return new DerbyOrderUserDAO(conn);
	}

	@Override
	public OrderItemDAO getOrderItemDAO(Connection conn)
			throws EShopDataStoreException {
		if (log.isTraceEnabled()){
			log.trace("Creating new DerbyOrderItemDAO");
		}
		return new DerbyOrderItemDAO(conn);
	}
}
